<?php
declare (strict_types = 1);

namespace app\services;

use app\model\ActivityList;
use app\services\BaseService;
/**
 * @mixin \think\Model
 */
class ActivityService extends BaseService
{
    public function __construct(ActivityList $model){
        $this->model = $model;
    }

    public function getActivityList($where){
        $data = $this->model->search($where)->order('add_time desc,activity_id desc')->select()->toArray();
        return $data;
    }

    public function addOne($params){
        $params['start_time'] = date("Y-m-d 00:00:00",intval($params['start_time'])/1000);
        $params['end_time'] = date("Y-m-d 23:59:59",intval($params['end_time'])/1000);
        $params['add_time'] = time();
        $params['update_time'] = time();
        return $this->model->insert($params);
    }

    public function updateOne($params){
        $params['start_time'] = date("Y-m-d 00:00:00",intval($params['start_time'])/1000);
        $params['end_time'] = date("Y-m-d 23:59:59",intval($params['end_time'])/1000);
        $params['update_time'] = time();
        return $this->model->update($params);
    }

    public function deleteOne($id){
        return $this->model->destroy($id);
    }
}
